﻿CREATE PROCEDURE [dbo].[utl_AssignCRUDSelectPermissions]

AS
BEGIN
    DECLARE @ID                INT
	DECLARE @SQL               NVARCHAR(MAX)
	DECLARE @DeveloperAccount  sysname
	
	SELECT @ID = MIN(d.ID)
	FROM   #Developer d
	
	WHILE @ID IS NOT NULL
	BEGIN
	    SELECT @DeveloperAccount = d.DeveloperAccount
	    FROM   #Developer d
	    WHERE  d.ID = @ID
	    
	    SET @SQL = 'EXECUTE [dbo].utl_AssignSelectToFunction @UserName = ''' + @DeveloperAccount + ''''
	    EXECUTE sp_executesql @SQL

	    SELECT @ID = MIN(d.ID)
	    FROM   #Developer d
	    WHERE  d.ID > @ID
	END
END

